<!DOCTYPE html>
<html lang="zh-cmn-Hans">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
		<title>ChinaBang Awards 2017</title>
		<link rel="stylesheet" href="../style/weui.css" />
		<link rel="stylesheet" href="./example.css" />
	</head>

	<body ontouchstart>
		<div class="weui-toptips weui-toptips_warn js_tooltips">错误提示</div>
		<div class="container" id="container"></div>
		<div class="page" style="opacity:1">
			<div class="weui-msg">
				<div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>
				<div class="weui-msg__text-area">
					<h2 class="weui-msg__title">投票成功</h2>
					<p class="weui-msg__desc" id="vote_result"></p>
				</div>
				<div class="weui-msg__opr-area">
					<p class="weui-btn-area">
						<a href="javascript:void(0);" class="weui-btn weui-btn_primary" onclick="$('#share_tip').slideDown('slow');">分享</a>
						<a href="javascript:void(0);" class="weui-btn weui-btn_default" id="item_detail">前往 NodeData 上查看公司详情</a>
					</p>
				</div>
				<div class="weui-msg__extra-area">
					<div class="weui-footer">
						<p class="weui-footer__links" id="go_back">
							<a href="javascript:void(0);" class="weui-footer__link">返回上一页</a>
						</p>
						<p class="weui-footer__text">Copyright &copy; 2016 TechNode</p>
					</div>
				</div>
			</div>
			<div class="vote_hide" id="share_tip">
				<img src="images/cb/share.png"/>
			</div>
			<input id="gimg" type="hidden" value="http://backstage.diamami.com.cn/html/image/1469772994075.jpg">
			<input id="name" type="hidden" value="浓情十月 调理特惠">
			<input id="desc" type="hidden" value="嗲妈咪10月双套餐活动 ">
		</div>
		<script src="example/js/util/jquery-1.8.3.min.js"></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script src="example/weui.min.js"></script>
		<script src="example/js/util/configs.js"></script>
		<script src="example/js/util/restUrls.js"></script>
		<script src="example/js/util/utils.js"></script>
		<script type="text/javascript">
			$(function () {
				$.ajax({
				debug: true,
				type: "post",
				url: restUrls.vote.getConfig,
				async: false,
				success: function(result) {
					if(result.data && result.data.rsData) {
						var wxConfig = result.data.rsData[0];
						$("#appId").val(wxConfig.appId);
						$("#timestamp").val(wxConfig.timestamp);
						$("#nonceStr").val(wxConfig.noncestr);
						$("#signature").val(wxConfig.signature);
						wx.config({
							appId: wxConfig.appId, // 必填，公众号的唯一标识
							timestamp: wxConfig.timestamp, // 必填，生成签名的时间戳
							nonceStr: wxConfig.noncestr, // 必填，生成签名的随机串
							signature: wxConfig.signature, // 必填，签名，见附录1
							jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
						});

						wx.ready(function() {
							var strurl = location.href;
							alert(strurl);
							var gimg = $("#gimg").val();
							var desc = $('#desc').val();
							var name = $('#name').val();
							wx.onMenuShareTimeline({
								title: name,
								desc: desc,
								link: strurl,
								imgUrl: gimg,
								trigger: function(res) {},
								success: function(res) {
									alert("cacacaca");
								},
								cancel: function(res) {
									// alert("已取消");
								},
								fail: function(res) {
									alert(JSON.stringify(res));
								}
							});

							wx.onMenuShareAppMessage({
								title: name,
								desc: desc,
								link: strurl,
								imgUrl: gimg,
								trigger: function(res) {},
								success: function(res) {
									alert("bababab");
								},
								cancel: function(res) {
									//alert("已取消");
								},
								fail: function(res) {
									alert(JSON.stringify(res));
								}
							});
						});

						wx.error(function(res) {
							alert(res.errMsg);
						});
					}
				}
			});
				var item_name = utils.getUrlParam("name");
				var words = "感谢您为 "+item_name+" 投上第 "+ utils.getUrlParam("count")+" 票";
				$("#vote_result").html(words);
				$("#item_detail").on("click", function() {
					var indexId = utils.getUrlParam("indexId");
					var type = utils.getUrlParam("type");
					var url_prefix = "http://data.technode.com/"
					
					if(type == 1 || type == 2) {
						window.location.href = url_prefix + "profile/" + indexId;	
					} else if(type == 3) {
						window.location.href = url_prefix + "startup/" + indexId;	
					}else if(type == 4) {
						window.location.href = url_prefix + "investor/" + indexId;
					}
				})
				
				$("#go_back").on("click", function() {
					var categoryId = utils.getUrlParam("voteCategoryId");
					window.location.href = "item.html?categoryId="+ categoryId;
				});
			});
		</script>
	</body>
</html>